
const routes = [
  {
    path: '/',
    name: "login",
    component: () => import('src/pages/login/login.vue')
  },
  {
    path: '/main',
    redirect: { name: 'match_container' },
    component: () => import('layouts/MyLayout.vue'),
    children: [
      {
        path: 'match',
        name: "match_container",
        redirect: { name: 'match_resource' },
        component: () => import('src/pages/match/match.vue'),
        // 设置meta下的keep_alive字段为true并且组件的name选项与路由的name选项相等可以缓存组件，只对本children有效
        children: [
          {
            path: 'resource',
            name: "match_resource",
            component: () => import('src/pages/match/resource/index.vue')
          },
          
          { 
            path: 'resource_edit',
            name: "match_resource_edit",
            component: () => import('src/pages/match/resource/edit.vue')
          },
          {
            path: 'manage',
            name: "match_manage",
            meta: {
              keep_alive: true
            },
            beforeEnter (to, from, next) {
              if (from.name === 'match_manage_edit' || from.name === null) {
                to.meta.keep_alive = true
              } else {
                to.meta.keep_alive = false
              }
              next()
            },
            component: () => import('src/pages/match/manage/index.vue')
          },
          {
            path: 'manage_edit',
            name: "match_manage_edit",
            component: () => import('src/pages/match/manage/edit.vue')
          },
          {
            path: 'team',
            name: "match_team",
            component: () => import('src/pages/match/team/index.vue')
          },
          {
            path: 'team_edit',
            name: "match_team_edit",
            component: () => import('src/pages/match/team/edit.vue')
          }
          
        ]
      },
      {
        path: 'order',
        name: "order_manage",
        component: () => import('src/pages/order/order.vue')
      },
      {
        path: 'permatch',
        name: "permatch_manage",
        component: () => import('src/pages/permatch/permatch.vue')
      },
      {
        path: 'inmatch',
        name: "inmatch_manage",
        component: () => import('src/pages/inmatch/inmatch.vue')
      },
      {
        path: 'overview',
        name: "overview_manage",
        component: () => import('src/pages/overview/overview.vue')
      },
      {
        path: 'setting',
        name: "setting_container",
        component: () =>import('src/pages/setting/setting.vue'),
        children: [
          {
            path: 'playrules',
            name: "setting_playrules",
            component: () =>import('src/pages/setting/playrules/index.vue'),
          },
          {
            path: 'playrules_edit',
            name: 'setting_playrules_edit',
            component: () => import('src/pages/setting/playrules/edit/edit.vue')
          },
          {
            path: 'playrules_collection',
            name: "setting_playrules_collection",
            component: () =>import('src/pages/setting/playrulesCollection/index.vue'),
          },
        ]
      }
    ]
  }
]

// Always leave this as last one
if (process.env.MODE !== 'ssr') {
  routes.push({
    path: '*',
    component: () => import('pages/error/Error404.vue')
  })
}

export default routes
